Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not pass ThreadPool to DesiredBalanceComputer #116590

Conversation

pxsalehi
Copy link
Member

Relates #115511 (comment). ThreadPool is used here only to get time. (I've extracted this out of #116333).

@pxsalehi pxsalehi added >non-issue :Distributed Coordination/Allocation All issues relating to the decision making around placing a shard (both master logic & on the nodes) labels Nov 11, 2024
@elasticsearchmachine elasticsearchmachine added Team:Distributed Coordination Meta label for Distributed Coordination team v9.0.0 labels Nov 11, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-distributed-coordination (Team:Distributed Coordination)

}

DesiredBalanceComputer(ClusterSettings clusterSettings, ShardsAllocator delegateAllocator, LongSupplier timeSupplierMillis) {
public DesiredBalanceComputer(ClusterSettings clusterSettings, LongSupplier timeSupplierMillis, ShardsAllocator delegateAllocator) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: lets keep the original order of arguments (clusterSettings, delegateAllocator, timeSupplierMillis), this could allow to minimize some of the changes such as:

            new DesiredBalanceComputer(clusterSettings, shardsAllocator, time::get) {
            new DesiredBalanceComputer(clusterSettings, time::get, shardsAllocator) {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This IS the original order (i.e. the existing public constructor), just replaced the threadpool with time supplier. :)

@@ -1349,7 +1353,7 @@ public ShardAllocationDecision decideShardAllocation(ShardRouting shard, Routing
}

private static DesiredBalanceComputer createDesiredBalanceComputer(ShardsAllocator allocator) {
return new DesiredBalanceComputer(createBuiltInClusterSettings(), mock(ThreadPool.class), allocator);
return new DesiredBalanceComputer(createBuiltInClusterSettings(), mock(ThreadPool.class)::relativeTimeInMillis, allocator);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we no longer need mock here

Suggested change
return new DesiredBalanceComputer(createBuiltInClusterSettings(), mock(ThreadPool.class)::relativeTimeInMillis, allocator);
return new DesiredBalanceComputer(createBuiltInClusterSettings(), () -> 0L, allocator);

unassignedIterator.removeAndIgnore(UnassignedInfo.AllocationStatus.NO_ATTEMPT, allocation.changes());
var desiredBalanceComputer = new DesiredBalanceComputer(
clusterSettings,
mockThreadPool::relativeTimeInMillis,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this mockThreadPool could be simplified as well

Suggested change
mockThreadPool::relativeTimeInMillis,
() -> currentTime.addAndGet(eachIterationDuration),

this way it might not be created at all above.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, right. didn't see that. thanks.

@pxsalehi pxsalehi added the auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label Nov 11, 2024
@elasticsearchmachine elasticsearchmachine merged commit 2cbc657 into elastic:main Nov 11, 2024
16 checks passed
@pxsalehi pxsalehi deleted the ps241111-removeThreadPoolFromDesiredBalanceComputer branch November 11, 2024 14:59
jozala pushed a commit that referenced this pull request Nov 13, 2024
Relates
#115511 (comment).
`ThreadPool` is used here only to get time. (I've extracted this out of
#116333).
afoucret pushed a commit to afoucret/elasticsearch that referenced this pull request Nov 14, 2024
Relates
elastic#115511 (comment).
`ThreadPool` is used here only to get time. (I've extracted this out of
elastic#116333).
alexey-ivanov-es pushed a commit to alexey-ivanov-es/elasticsearch that referenced this pull request Nov 28, 2024
Relates
elastic#115511 (comment).
`ThreadPool` is used here only to get time. (I've extracted this out of
elastic#116333).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) :Distributed Coordination/Allocation All issues relating to the decision making around placing a shard (both master logic & on the nodes) >non-issue Team:Distributed Coordination Meta label for Distributed Coordination team v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants